package com.example.rabbitmq.controller.rabbitmq;


import com.example.rabbitmq.service.IRabbitmqService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class RabbitmqController {
    @Resource
    private IRabbitmqService rabbitmqService;

    /**
     * 生产消费模式
     *
     * @return success
     */
    @GetMapping("/sendWork")
    public Object sendWork() {
        rabbitmqService.sendWork();
        return "发送成功...";
    }

    /**
     * 发布订阅模式
     *
     * @return success
     */
    @RequestMapping("/sendPublish")
    public String sendPublish() {
        rabbitmqService.sendPublish();
        return "发送成功...";
    }

    /**
     * topic 模式
     *
     * @return success
     */
    @RequestMapping("/sendTopic")
    public String sendTopic() {
        rabbitmqService.sendTopic();
        return "发送成功...";
    }

    /**
     * 确认机制
     *
     * @return success
     */
    @RequestMapping("/sendConfirm")
    public String sendConfirm() {
        rabbitmqService.sendConfirm();
        return "发送成功...";
    }

    /**
     * 返回机制
     *
     * @return success
     */
    @RequestMapping("/sendReturn")
    public String sendReturn() {
        rabbitmqService.sendReturn();
        return "发送成功...";
    }
    /**
     * 测试消费者ack
     *
     * @return success
     */
    @RequestMapping("/sendNeedAck")
    public String sendNeedAck() {
        rabbitmqService.sendNeedAck();
        return "发送成功...";
    }

    /**
     * 测试死信队列
     *
     * @return success
     */
    @RequestMapping("/sendDead")
    public String sendDead() {
        rabbitmqService.sendDead();
        return "发送成功...";
    }

}
